1. Field of the Invention
The present invention relates to a counter device, and a counting method using a non-volatile memory.
Priority is claimed on Japanese Patent Application No. 2004-351590, filed Dec. 3, 2004, and Japanese Patent Application No. 2004-351591, filed Dec. 3, 2004, the contents of which are incorporated herein by reference.
2. Description of Related Art
A printer and a copier control a large number of counters by a non-volatile memory (flash memory: registered trademark). The counter counts the number of printed sheets and is also used for accounting purpose. Therefore a high reliability is required. The non-volatile memory the reliability is described as the bits are used more frequently. Therefore, the manufacturer sets a guaranteed number of writings. If the number of writings exceeds the set number, the reliability of the non-volatile memory is remarkably decreased. In this case, it is not guaranteed by the manufacturer.
In the non-volatile memory, due to the device property thereof, the counter value can not be overwritten in the same area in the non-volatile memory each time the counter is updated. That is, in the non-volatile memory, the memory region is divided into units called sectors, and at the time of updating the data, in order to turn ON the bit that has been OFF, it is necessary to once perform sector erasure which is to turn ON the bits (0×ff: hexadecimal number “ff”) of all the data in the sector, and then to write in the new data.
Generally, as a counter, as shown in FIG. 7, “0” is previously written in all bits, so that the bits are counted up from the lower bit one by one at the time of counting. As described above, in the non-volatile memory, in order to turn ON the bit that has been OFF, it is necessary to once perform the sector erasure which is to turn ON the bits (0×ff) of all the data in the sector.
Consequently, as shown in FIG. 8, in this case, each time the counter value is updated, the sector erasure is performed, generating writings having the same number of bits of the counter. Therefore, as described above, the reliability of the non-volatile memory is rapidly decreased. In order to increase the reliability of the counter value, the number of rewritings is desirably as low as possible.
According to Japanese Unexamined Patent Application, First Publication No. 2001-118391, and Japanese Unexamined Patent Application, First Publication No. H11-110983, several techniques for decreasing the number of sector erasures at the time of updating the counter value have been proposed. In the conventional techniques, as shown in FIG. 9, “1” is previously written in all the bits of the counter, so that the counting is performed by bit OFF. Therefore, the bit “1” is changed to the bit “0”. By turning the bit from ON to OFF, the number of bytes of the counter can be counted without the sector erasure.
However, in the prior art described above, since number of bits equals maximum counter value, the same number of bits as that of the maximum counter value is required. For example, if several hundred thousand units are counted, several hundred thousand bits are required, causing a problem in that, in reality, installation is difficult, considering the memory capacity and the cost.